﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Planisoft.Entities;
using Planisoft.BL;
using Microsoft.Practices.Unity;

namespace Planisoft.ClienteMvcWeb.Controllers
{
    public class UbigeoController : Controller
    {
        //
        // GET: /Ubigeo/
        [Dependency]
        public IUbigeoProvinciaBL  UbigeoProvinciaBL { get; set; }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult getServiceProvinciasByIdDepJSON(Int32 id)
        {
            var query = from p in UbigeoProvinciaBL.GetFromProvinciaByDepId(id)
                        select new
                        {
                            value = p.IdUbiProv,
                            label = p.DescUbiProv
                        };

            return Json(query.ToList(), JsonRequestBehavior.AllowGet); 
        }

        [Dependency]
        public IUbigeoDistritoBL UbigeoDistritoBL { get; set; }

        public ActionResult getServiceDistritoByIdProvJSON(Int32 id) 
        {
            var query = from d in UbigeoDistritoBL.GetFromDistritoByProvinciaId(id)
                        select new
                        {
                            value = d.IdUbiDtto,
                            label = d.DescUbiDtto                            
                        };

            return Json(query.ToList(), JsonRequestBehavior.AllowGet);
        }

    }
}
